<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,SiTuQingYou.vo.*,SiTuQingYou.util.*"
    pageEncoding="UTF-8"%>
    <%
     String path = request.getContextPath();
    %>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="<%=path %>/houtai/js/jquery-3.3.1.min.js"></script>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">

  $(document).ready(load);

  function load()
  {
      $("#addGuider").submit(sumb);
  }
  
  function sumb(){
	   var fPhone = checkPhoneNumber();
	   var fPrice = checkPrice();
	   var fInformation = checkInformation();
	   return fPhone&&fPrice&&fInformation;
  }

  //手机号
  function checkPhoneNumber(){
	  var reg = /^(\d{11})$/;
	  var thePhone = $("#phoneid").val();
	  var flagPhone = reg.test(thePhone);
	  if(flagPhone)
	  {
		  $("#phoneid").next().html("");
		  return true;
	  }
	  else
	  {
		  $("#phoneid").next().html("手机号码固定11位数字");
		  $("#phoneid").next().css("color","red");
		  return false;
	  }
  }
  
  //导游价格
  function checkPrice(){
  	var reg = /^(((\d{2,})+(.\d{1,2}))|(\d{2,}))$/;
  	var thePrice = $("#priceid").val();
  	var flagPrice = reg.test(thePrice);
  	if(flagPrice)
  	{
  		$("#priceid").next().html("");
  		return true;
  	}
  	else
  	{
  		$("#priceid").next().html("不符合格式规范");
  		$("#priceid").next().css("color","red");
  		return false;
  	}
  }
  
  //导游信息
  function checkInformation(){
  	
  	var theInformation = $("#informationid").val();
  	var flagInformation =theInformation.length>=10?true:false ;
  	if(flagInformation)
  	{
  		$("#informationid").next().html("");
  		return true;
  	}
  	else
  	{
  		$("#informationid").next().html("请至少输入10个字符");
  		$("#informationid").next().css("color","red");
  		return false;
  	}
  }

</script>
   <jsp:include page="/GuiderServlet"><jsp:param value="lookForInfo" name="method"/></jsp:include>
   <%
      Guider g = (Guider)request.getAttribute("guider");
   %>
   <form enctype="multipart/form-data" id="addGuider" method="post" action="/SiTuQingYou/GuiderServlet?method=reviseGuider&theid=<%=g.getId()%>">
      <div>要修改导游的姓名：<%=g.getGuidername() %></div>
      <div>手机号：<input type="text" maxlength="11" value="<%=g.getGuiderphone()%>" id="phoneid" name="phonename" onblur="checkPhoneNumber()"><span></span></div>
      <div>导游费(每天)：<input type="text" maxlength="8" value="<%=g.getGuiderprice()%>" id="priceid" name="pricename" onblur="checkPrice()">元<span></span></div>
      <div>导游信息：<textarea rows="8" cols="20" id="informationid" name="informationname" onblur="checkInformation()"><%=g.getGuiderinfo() %></textarea><span></span></div>
      <div>修改头像：<input type="file" name="headname" id="headid" ></div>
       <jsp:include page="../ScenehomeServlet">
			<jsp:param value="allcity" name="method"/>
			</jsp:include>
			请选择景点城市：
     <select name="cityid"   id="city" >
   
<option value="<%=g.getCity().getId()%>" ><%=g.getCity().getCityname() %></option>
<option>-----------</option>
          <%
     ArrayList<City> allcity = (ArrayList<City>)request.getAttribute("allcity");
								for(City city:allcity){
     %>	
      <option value="<%=city.getId() %>"  >   <%=city.getCityname()%> </option><%} %>
    </select>
    <br><br>
      <input type="submit" value="确认修改" class="btnclosepanel">
   </form>
   
</body>
</html>